package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.base.BaseDomain;
import cn.wolfcode.p2p.base.util.BitStateUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;;

/**
 *    
 *    个人信息
 *    @author 
 *    @since 2018-11-24 13:13:43
 */
@Getter@Setter
@Accessors(chain = true)
public class UserInfo extends BaseDomain {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
     * 乐观锁
     */
    private Integer version = 0;

    /**
     * 位状态码
     */
    private Long bitState = 0L;

    /**
     * 身份证号码
     */
    private String idNumber;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 手机号码
     */
    private String phoneNumber;

    /**
     * 电子邮箱
     */
    private String email;

    /**
     * 实名认证信息ID
     */
    private Long realAuthId;

    /**
     * 视频认证信息ID
     */
    private Long videoAuthId;

    /**
     * 婚姻情况
     */
    private SystemDictionaryItem marriage;

    /**
     * 子女数量情况
     */
    private SystemDictionaryItem kidCount;

    /**
     * 教育背景情况
     */
    private SystemDictionaryItem educationBackground;

    /**
     * 住房条件情况
     */
    private SystemDictionaryItem houseCondition;

    /**
     * 月收入情况
     */
    private SystemDictionaryItem incomeGrade;


    /**
     * 判断是否满足条件
     */
    public boolean getBorrowble(){
        return this.getHasBasicInfo() && this.getHasRealAuth() && this.getHasVideoAuth();
    }
    /**
     * 判断是否已做实名认证
     */
    public boolean getHasRealAuth(){
        return BitStateUtil.hasState(this.bitState, BitStateUtil.OP_REAL_AUTH);
    }
    /**
     * 判断是否已做实名认证
     */
    public boolean getHasVideoAuth(){
        return BitStateUtil.hasState(this.bitState, BitStateUtil.OP_VIDEO_AUTH);
    }
    /**
     * 判断是否已填写基本资料
     */
    public boolean getHasBasicInfo(){
        return BitStateUtil.hasState(this.bitState, BitStateUtil.OP_BASIC_INFO);
    }

    /**
     * 新增状态码
     */
    public void addNewState(long newState){
        this.bitState = BitStateUtil.addState(this.bitState, newState);
    }

    /**
     * 删除某个状态码
     */
    public void removerState(Long oldState){
        this.bitState = BitStateUtil.removeState(this.bitState, oldState);
    }

    /**
     * 判断是否存在一个借款处于流程中
     */
    public boolean getHasBidRequestInProcess(){
        return BitStateUtil.hasState(this.bitState, BitStateUtil.OP_HAS_BIDREQUEST_PROCESS);
    }

}